import menuManage from '@/api/menu';
import videoManage from '@/api/video';
import artManage from '@/api/works';
import aboutWorksManage from '@/api/impression';
import artisManage from '@/api/artis';

export default (await import('vue')).defineComponent({
name: 'banner-view',
components: {
paging,
},
data() {
return {
list: [],
menuList: [],
isShowDialog: false,
updId: '',
workList: [],
params: {
type: '',
work_name: '',
about_type: '',
art_id: '',
art_name: '',
introduction: '',
title_page: '',
video_url: '',
opus_id: [],
},
rules: {
type: [{ required: true, message: '请选择类型', trigger: 'change' }],
},
aboutType: ['', '自然景观', '人文景观', '地标建筑', '艺术创作'],
type: ['', '图片', '视频'],
arts: [],
loading: false,
};
},
async mounted() {
this.refresh();
this.getMenuList();
artisManage.getArtis({ notPagination: true }).then((res) => {
this.arts = res.item_list;
});
},
methods: {
refRemoteMethod(query) {
// if (!query) return;
this.loading = true;
let userRes = await artisManage.getArtis({ key: query, notPagination: true });
this.arts = userRes.item_list;
this.loading = false;
},
async remoteMethod(query) {
this.loading = true;
let userRes = await artisManage.getArtis({ key: query, notPagination: true });
this.arts = userRes.item_list;
this.loading = false;
},
// 查看大图
lookBig(data) {
console.log(data);
if (data.opus_id && data.opus_id.length > 0) {
let { BasicDraw, BigImageShow } = require('../../../utils/main');
let basicDraw = new BasicDraw(); // 创建基础渲染类
basicDraw.start(); // 开始渲染
new BigImageShow().showBigImg(data.opus_id[0].id);

document.getElementById('bigIamgeClose').addEventListener('click', (e) => {
basicDraw.dispose();
e.stopPropagation();
});
}
},
getBigImg,
changeArt(e) {
this.arts.forEach((item) => {
if (item.data_id === e) {
this.params.art_name = item.name;
}
});
},
updAbout(data_id, m) {
this.updId = data_id;
this.isShowDialog = true;
this.params = { ...m };
this.getWorks();
},
async delBanner(data_id) {
this.$alert('是否确定删除作品', '删除', {
confirmButtonText: '确定',
callback: async (action) => {
if (action === 'confirm') {
await aboutWorksManage.delAboutWorks(data_id);
this.refresh();
}
},
});
},
refresh() {
this.$refs.page.refresh();
},
async getMenuList() {
let res = await menuManage.getMenu();
this.menuList = res.item_list;
},
getList(callback) {
aboutWorksManage.getAboutWorks().then((res) => {
let total = res.total_count;
this.list = res.item_list;
callback(this.list, total);
});
},
async dialogConfirm() {
this.$refs.dataParams.validate(async (valid) => {
if (valid) {
let res = null;
if (this.updId) {
res = await aboutWorksManage.updAboutWorks(this.updId, this.params);
} else {
res = await aboutWorksManage.setAboutWorks(this.params);
}
if (res) {
this.isShowDialog = false;
this.refresh();
}
}
});
},
onClose() {
this.updId = '';
this.params = {
text: '',
};
},
async beforeAvatarUpload(file, id) {
const formData = new FormData();
formData.append('上传的key值', file);
await aboutWorksManage.setAboutWorksImage(id, formData);
this.refresh();
},
async beforeAvatarUploadVideo(file, id) {
const formData = new FormData();
formData.append('上传的key值', file);
await aboutWorksManage.setAboutWorksVideo(id, formData);
this.refresh();
},
async beforeAvatarUploadBigImg(file, id) {
const formData = new FormData();
formData.append('上传的key值', file);
let url = await artManage.uploadMap(formData);
let opus_id = await artManage.imageMap({
image_list: [
{
image_src_url: url,
image_src_type: 'local',
image_name: url.split('/')[2],
type: 1,
access_type: 0,
note: '',
},
],
});
await aboutWorksManage.updAboutWorks(id, { opus_id });
this.$message.success('上传成功');
},
getWorks() {
let methods = [0, artManage.getArt, videoManage.getVideoType];
let get = methods[this.params.type];
get().then((res) => {
this.workList = res.item_list;
});
},
checkWork(m) {
console.log('m', m);
this.params.art_name = m.art_name;
this.params.art_id = m.data_id;
this.params.introduction = m.work_detail || '';
this.params.title_page = m.video_page || '';
this.params.video_url = m.video_path || '';
this.params.work_name = m.video_name || m.name;
this.isShowDialog = false;
this.dialogConfirm();
},
},
});
